<?php
try{
    include '../ini.php';
    $page=isset($_GET['page'])?$_GET['page']:1;
    $search=$dt_xl_security->vn_str_filter($_GET['search']);
    $start=($page-1)*2;
    $list_search=$dt_xl_product->read_products($search,$start);
    if($list_search == NULL){
        throw new Exception('Không tìm thấy sản phẩm theo yêu cầu');
    }
    $sum=ceil(($dt_xl_product->list_product_search($_GET['search']))/2);
    $pagination='';
    if($sum>1){
        $pagination=pagination($page,$sum);
    }
    $dt_smarty->assign('pagination',$pagination);
    $dt_smarty->assign('list_search',$list_search);
    $contentForLayout=$dt_smarty->fetch('tag/tag.tpl');
    $dt_smarty->assign('titleForLayout',"".$_GET['search']."");
    $dt_smarty->assign('contentForLayout',$contentForLayout);
    $dt_smarty->display('layouts/default.tpl');
 
}catch(Exception $e){
    $dbh=NULL;
    $_SESSION['msg']=$e->getMessage();
    $_SESSION['type_msg']='error';
    header('Location: /');
}